package com.cari.oa.service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cari.oa.dao.BaseDao;
import com.cari.oa.dao.CommentDao;
import com.cari.oa.domain.CommentEntity;

@Service
@Transactional(rollbackFor = Exception.class)
public class CommentService extends BaseService<CommentEntity> {
	
	public static final Integer CMT_COST = 1;
	public static final Integer CMT_PRJ = 2;
	public static final Integer CMT_REQ = 3;
	public static final Integer CMT_BUG = 4;
	public static final Integer CMT_OAREPOSITORY = 5;
	
	@Resource
	private CommentDao commentDao;
	
	/**
     * 根据项目id获取项目留言列表
     * @param enname 系统用户英文名
     * @return 系统实体对象
     */
	public List<CommentEntity> getListByObjID(String id, Integer type) {
    	return commentDao.getListByObjID(id, type);
    }
	
	/**
     * 获取最新留言时间及其相关项目id
     * @return
     * guotingting 2013-1-24 下午3:13:26
     */
	public List<Map<String,Date>> getMaxDateList(Integer type, Set<String> objectIds) {
    	return commentDao.getMaxDateList(type, objectIds);
    }
	
	@Transactional(readOnly = true)
	public Long getCountByObjId(String Id){
		return commentDao.getCountByObjId(Id);
	}

	@Override
	public BaseDao<CommentEntity> getDao() {
		return commentDao;
	}

}
